const app = getApp();
const { AskComponent } = app._require("common/index");

AskComponent({
   properties: {
        items: {
            type: Array,
            value: [],
          }
    },
    data: {
        currentSrc: "",
    },
    lifetimes: {
        attached() {
            // 在组件实例进入页面节点树时执行
            this.formatValue();
        },
        detached() {
            // 在组件实例被从页面节点树移除时执行
        },
    },
    methods: {
        formatValue() {
            this.setData({
                currentSrc: this.data.src || this.data.errorSrc,
            });
        },
        onError(e) {
            this.setData({
                currentSrc: this.data.errorSrc,
            });
            // console.log("error", e)
            this.$emit("error", e.detail);
        },
        onLoad(e) {
            // console.log("load", e);
            this.$emit("load", e.detail);
        },
    },
});
